<template>
	<view class="contaier">
		<u-sticky>
			<!-- 只能有一个根元素 -->
			<view class="sticky">
				<u-search :show-action="true" action-text="搜索" :animation="true"></u-search>
			</view>
		</u-sticky>
		<mescroll-body ref="mescrollRef" safearea @init="mescrollInit" @down="downCallback" @up="upCallback" top="30">
			<view class="list-content">
				<view @click="handleDetail(item)" class="cardBox" v-for="(item,index) in dataList" :key="index">
					<view class="cardTitle">{{item.customerName}}</view>
					<view class="cu-list menu">
						<view class="cu-item">
							<text class="text-grey">纳税人识别号：</text>
							<text class="text-balck text-df">{{item.socialCreditCode}}</text>
						</view>
						<view class="cu-item">
							<text class="text-grey">法人：</text>
							<text class="text-balck text-df">{{item.legalRepresentative}}</text>
						</view>
						<view class="cu-item">
							<text class="text-grey">成立日期：</text>
							<text
								class="text-balck text-df">{{item.establishmentDate?item.establishmentDate.split(' ')[0]:''}}</text>
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import config from '@/common/js/config.js'
	export default {
		mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
		data() {
			return {
				dataList: []
			}
		},
		onLoad() {
			uni.showLoading({
				title: '加载中...',
				mask: true
			});
			setTimeout(function() {
				uni.hideLoading();
			}, 2000);
		},
		onShow() {

		},
		methods: {

			upCallback(page) {

				const userProvider = uni.getStorageSync(config.Global.cache + '_UserProvider');



				let httpData = {
					currentPage: page.num,
					pageSize: page.size,
					userId: userProvider.id,
				}
				this.$helper.ajax({
					url: `/api/Jiushi/Customerbase/GetCuseBusList`,
					method: 'GET',
					data: httpData,
					success: res => {
						console.log(res)
						let curPageLen = res.data.data.list.length;
						let totalSize = res.data.data.pagination.total;
						this.mescroll.endBySize(curPageLen, totalSize);
						if (page.num == 1) {
							this.dataList = []
						}
						this.dataList = this.dataList.concat(res.data.data.list);
					}
				});
			},
			handleDetail(detail) {
				let url = '../../customer/customer?id=' + detail.id
				uni.navigateTo({
					url: url
				})

			},
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
	};
</script>

<style lang="scss" scoped>
	.contaier {
		background-color: #F0F2F6;
	}

	.sticky {
		background: #FFFFFF;
		width: 100%;
		margin: 0;
		padding: 24rpx;
	}


	.list-content {
		padding: 0 24rpx;
	}

	.cardBox {
		width: 100%;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		padding: 20rpx 24rpx;
		margin-bottom: 24rpx;

		.cardTitle {
			color: #000000;
			font-size: 34rpx;
			font-weight: 500;
		}
	}

	.fgLine {
		width: 100%;
		height: 1px;
		background-color: #DDDDDD;
		margin: 20rpx auto;
	}

	.cu-list.menu>.cu-item {
		padding: 0 !important;
		min-height: 30rpx;
		margin-top: 16rpx !important;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.cu-list.menu>.cu-item:after {
		border: none;
	}
</style>